/**
 * Created by wdcy336 on 2015/6/8.
 */
Ext.define('Monkey.view.authentication.Login', {
    extend: 'Monkey.view.authentication.AuthViewport',
    xtype: 'view-login',
    requires: [
        'Monkey.view.authentication.AuthModel',
        'Monkey.view.authentication.AuthController'
    ],
    controller: 'ctrl-auth',
    viewModel: 'vm-auth',

    items: [{
        xtype: 'window',
        title: '<span class="x-fa fa-bar-chart">&nbsp;你好，请登录...</span>',
        autoShow: true,
        height: 330,
        width: 350,
        frame: true,
        draggable: false,
        closable: false,
        resizable: false,
        layout: 'border',
        items: [{
            border: false,
            region: 'north',
            bodyStyle: "text-align:center;padding-top:20px",
            items: {
                xtype: 'image',
                alt: '项目logo',
                src: 'resources/images/logo.png',
                height: 100
            }
        }, {
            region: 'center',
            bodyStyle: "padding:20px 40px 10px 40px",
            border: false,
            buttonAlign: 'center',
            xtype: 'form',
            reference: 'formPanel',
            defaults: {
                labelWidth: 50,
                labelAlign: 'right',
                anchor: '100%'
            },
            defaultType: 'textfield',
            items: [{
                bind: '{account}',
                allowBlank: false,
                emptyText: '请输入帐号',
                fieldCls: 'user',
                fieldStyle: 'background-repeat: no-repeat;background-position: left center;padding-left: 20px',
                fieldLabel: '账&nbsp;&nbsp;&nbsp;号&nbsp;',
                listeners: {
                    specialKey: 'enterEvent'
                }
            }, {
                bind: '{password}',
                allowBlank: false,
                emptyText: '请输入密码',
                fieldCls: 'key',
                fieldStyle: 'background-repeat: no-repeat;background-position: left center;padding-left: 20px',
                fieldLabel: '密&nbsp;&nbsp;&nbsp;码&nbsp;',
                inputType: 'password',
                listeners: {
                    specialKey: 'enterEvent'
                }
            }, {
                xtype: 'panel',
                layout: 'column',
                border: false,
                items: [{
                    bind: '{code}',
                    columnWidth: .6,
                    xtype: 'textfield',
                    labelWidth: 50,
                    labelAlign: 'right',
                    anchor: '100%',
                    fieldCls: 'picture-empty',
                    fieldStyle: 'background-repeat: no-repeat;background-position: left center;padding-left: 20px',
                    allowBlank: false,
                    fieldLabel: '验证码&nbsp;',
                    listeners: {
                        specialKey: 'enterEvent'
                    }
                }, {
                    columnWidth: .4,
                    padding: '0 0 0 4px',
                    xtype: 'image',
                    src: Monkey.URL.JCAPTCHA_URL,
                    alt: '看不清请点击',
                    height: 28,
                    listeners: {
                        click: {
                            element: 'el',
                            fn: function (a, b) {
                                b.src = Monkey.URL.JCAPTCHA_URL;
                            }
                        }
                    }
                }]
            }, {
                fieldLabel: '&nbsp;',
                labelSeparator: '',
                xtype: 'checkboxfield',
                boxLabel: '记住密码',
                name: 'rememberMe',
                bind: '{rememberMe}'
            }],
            buttons: [{
                formBind: true,
                iconCls: 'x-fa fa-sign-in',
                text: '登陆',
                handler: 'onLoginClick'
            }, {
                iconCls: 'x-fa fa-repeat',
                text: '重置',
                handler: 'resetForm'
            }]
        }]
    }]

});
